import {Component, inject} from '@angular/core';
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';

import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzDatePickerModule } from 'ng-zorro-antd/date-picker';
import { NzFormModule } from 'ng-zorro-antd/form';
import { NzTimePickerModule } from 'ng-zorro-antd/time-picker';
import {NzOptionComponent, NzSelectComponent} from 'ng-zorro-antd/select';
import {NzInputDirective} from 'ng-zorro-antd/input';
import {CamundaService} from '../../../services/camunda.service';
import {NzMessageService} from 'ng-zorro-antd/message';

@Component({
  selector: 'app-ask-for-level-start',
  standalone: true,
  imports: [ReactiveFormsModule, NzButtonModule, NzDatePickerModule, NzFormModule, NzTimePickerModule, NzOptionComponent, NzSelectComponent, NzInputDirective],
  templateUrl: './ask-for-level-start.component.html',
  styleUrl: './ask-for-level-start.component.css'
})
export class AskForLevelStartComponent {

  constructor(private camundaService: CamundaService,
              private messageService: NzMessageService) {
  }

  //表单数据
  private fb = inject(FormBuilder);
  validateForm = this.fb.group({
    type: this.fb.control<Number | null>(null),
    rangePicker: this.fb.control<[Date, Date] | null>(null),
    reason: this.fb.control<String | null>(null)
  });

  //发起流程
  submitForm(): void {
    console.log("发起一个请假流程请求!")
    this.camundaService.submit_start_form("ask_for_level", this.validateForm.value)
    this.messageService.create("success", "流程审批已提交");
  }
}
